bitkeeper revision 1.1159.186.1 (41a2662eF1hWrCE7SFR6NRrcnlh3Lg)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 22 Nov 2004 22:20:30 +0000 (22:20 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 22 Nov 2004 22:20:30 +0000 (22:20 +0000)
xfrd fixes from Charles Coffing.

tools/xfrd/Makefile
tools/xfrd/debug.h
tools/xfrd/sxpr_parser.c
tools/xfrd/xen_domain.c
tools/xfrd/xfrd.c

index c1478ce690cc283634f2a678e1780f403b960fcb..2330d829c4980c263685b8d2eab734bc5d626064 100644 (file)
@@ -26,11 +26,15 @@ XFRD_PROG_OBJ += $(UTIL_LIB)
 # Define to use stubs, undefine to use the real Xen functions.
 #CPPFLAGS += -D _XEN_XFR_STUB_
 
+ifeq ($(SXPR_DEBUG),1)
+CPPFLAGS += -D _XEN_XFR_STUB_ -D SXPR_PARSER_MAIN
+endif
+
 CC := gcc
 
 CFLAGS += -g
 CFLAGS += -Wall
-CFALGS += -Werror
+CFLAGS += -Werror
 CFLAGS += $(INCLUDES)
 # Make gcc generate dependencies.
 CFLAGS += -Wp,-MD,.$(@F).d
index 1f5a19d54d06ad9d7ab335895099cdfd0ad4b099..3df5345095ab252beb5d9f9beb5d8fa5cfe34304 100644 (file)
@@ -45,6 +45,7 @@
 #else
 
 #include <stdio.h>
+#include <unistd.h>
 
 #ifdef DEBUG
 
index dbe386a8622cf64b9ffa72bce77809c2c77d7ba4..c679d6cfb87ec475ce15147772316f43156ab7a0 100644 (file)
@@ -242,6 +242,8 @@ int Parser_pop(Parser *p){
     int err = 0;
     ParserState *s = p->state;
     p->state = s->parent;
+    if (p->start_state == s)
+        p->start_state = NULL;
     ParserState_free(s);
     return err;
 }
@@ -374,7 +376,7 @@ Sxpr Parser_get_all(Parser *p){
     if(CONSP(p->val)){
         v = p->val;
         p->val = ONONE;
-    } else if(CONSP(p->start_state->val)){
+    } else if(p->start_state && CONSP(p->start_state->val)){
         v = p->start_state->val;
         p->start_state->val = ONULL;
         v = nrev(v);
@@ -808,26 +810,13 @@ int at_eof(Parser *p){
     return p->eof;
 }
 
-//#define SXPR_PARSER_MAIN
 #ifdef SXPR_PARSER_MAIN
 /* Stuff for standalone testing. */
 
 #include "file_stream.h"
 #include "string_stream.h"
 
-int stringof(Sxpr exp, char **s){
-    int err = 0;
-    if(ATOMP(exp)){
-        *s = atom_name(exp);
-    } else if(STRINGP(exp)){
-        *s = string_string(exp);
-    } else {
-        err = -EINVAL;
-        *s = NULL;
-    }
-    return err;
-}
-
+extern int stringof(Sxpr exp, char **s);
 int child_string(Sxpr exp, Sxpr key, char **s){
     int err = 0;
     Sxpr val = sxpr_child_value(exp, key, ONONE);
@@ -835,22 +824,7 @@ int child_string(Sxpr exp, Sxpr key, char **s){
     return err;
 }
 
-int intof(Sxpr exp, int *v){
-    int err = 0;
-    char *s;
-    unsigned long l;
-    if(INTP(exp)){
-        *v = OBJ_INT(exp);
-    } else {
-        err = stringof(exp, &s);
-        if(err) goto exit;
-        err = convert_atoul(s, &l);
-        *v = (int)l;
-    }
- exit:
-    return err;
-}
-
+extern int intof(Sxpr exp, int *v);
 int child_int(Sxpr exp, Sxpr key, int *v){
     int err = 0;
     Sxpr val = sxpr_child_value(exp, key, ONONE);
index abc7b7dc3c0c2eb34c122cf6cd98e464003a220a..64567900b4e0dc2477bb802d867d3ffc49d3a5d2 100644 (file)
@@ -83,7 +83,7 @@ int xen_domain_snd(Conn *xend, IOStream *io,
     }
     
     dom = 99;
-    err = domain_suspend(dom, xend);
+    err = domain_suspend(xend, dom);
     IOStream_close(io);
   exit:
 #else 
index 236b67755badf8d3bc1148477d586fc1a02c63ee..136a614aa3490843ad34fcbf327910ead6f6f649 100644 (file)
@@ -171,6 +171,25 @@ void usage(int err){
     exit(err ? 1 : 0);
 }
 
+typedef struct Args {
+    int bufsize;
+    unsigned long port;
+    int verbose;
+    int compress;
+} Args;
+
+/** Transfer states. */
+enum {
+    XFR_INIT,
+    XFR_HELLO,
+    XFR_STATE,
+    XFR_RUN,
+    XFR_FAIL,
+    XFR_DONE,
+    XFR_MAX
+};
+
+#ifndef SXPR_PARSER_MAIN
 /** Short options. Options followed by ':' take an argument. */
 static char *short_opts = (char[]){
     OPT_PORT,     ':',
@@ -190,23 +209,12 @@ static struct option const long_opts[] = {
     { NULL,         0,                 NULL, 0            }
 };
 
-typedef struct Args {
-    int bufsize;
-    unsigned long port;
-    int verbose;
-    int compress;
-} Args;
+/** Xfrd arguments. */
+static Args _args = {};
 
-/** Transfer states. */
-enum {
-    XFR_INIT,
-    XFR_HELLO,
-    XFR_STATE,
-    XFR_RUN,
-    XFR_FAIL,
-    XFR_DONE,
-    XFR_MAX
-};
+/** Xfrd arguments. */
+static Args *args = &_args;
+#endif
 
 /** Initialize an array element for a constant to its string name. */
 #define VALDEF(val) { val, #val }
@@ -318,12 +326,6 @@ int XfrState_first_err_state(XfrState *s){
     return s->err_state;
 }
 
-/** Xfrd arguments. */
-static Args _args = {};
-
-/** Xfrd arguments. */
-static Args *args = &_args;
-
 /** Set xfrd default arguments.
  *
  * @param args arguments to set
@@ -1212,6 +1214,7 @@ int xfrd_main(Args *args){
     return err;
 }
 
+#ifndef SXPR_PARSER_MAIN
 /** Parse command-line arguments and call the xfrd main program.
  *
  * @param arg argument count
@@ -1265,4 +1268,4 @@ int main(int argc, char *argv[]){
     }
     return (err ? 1 : 0);
 }
-
+#endif